/* 
 * File:   QueryBuilder.hpp
 * Author: Faisal
 *
 * Created on April 27, 2012, 8:39 PM
 *
 * Description:
 *		A utitlity class to guild the where clause for a query and substitue the parameter token with the provider specific tags.
 */

#ifndef HQueryBuilder_DL

#define HQueryBuilder_DL

#include "../Include/Shared.hpp"
#include <Common/Include/QueryModifierBase.hpp>
#include <Common/Include/ParameterInfo.hpp>
#include <Common/Include/FilterType.hpp>
#include <regex>

#include <sstream>

using Supetronix::PersistO::Common::QueryModifierBase;
using Supetronix::PersistO::Common::ParameterInfo;

using std::string;
using std::stringstream;

namespace Supetronix
{
	namespace PersistO
	{
		namespace DL
		{
			class QueryBuilder
			{
			public:
				/*
				*	Methods
				*/

				//loop through the query modifier parameters list and build the where clause for the select query
				static string BuildWhereClause(const QueryModifierBase* queryModifier);

				//replace the parameter token with the provider specific tags
				static void TransformQueryParameters(string& query, const ConnectionSourceType& connectionType);

			private:
				/*
				*	Methods
				*/

				//return the string name for the SQL parameters, like "And", "OR" etc
				static string SqlFilterString(FilterType& queryFilterType);

				//keyword to use for the query parameter name
				const static string WhereParamTag;
			};
		}
	}
}


#endif